package org.ndx.jsg.input;

import java.io.File;

import org.apache.tika.metadata.Metadata;
import org.ndx.jsg.FileInfos;

/**
 * As default, file infos are comparable upon their name, then modification date
 * @author ndx
 *
 */
public abstract class AbstractFileInfo implements Comparable<FileInfos>{

	/**
	 * Source file
	 */
	protected final File file;
	
	/**
	 * Relative path from file to its base input path
	 */
	protected final String relativePath;

	private final Metadata metadata;

	public AbstractFileInfo(File file, String relativePath, Metadata metadata) {
		super();
		this.file = file;
		this.relativePath = relativePath;
		this.metadata = metadata;
	}

	public File getFile() {
		return file;
	}

	public String getMimeType() {
		return metadata.get(Metadata.CONTENT_TYPE);
	}

	public String getRelativePath() {
		return relativePath;
	}


	@Override
	public int compareTo(FileInfos o) {
		return file.getAbsoluteFile().getName().compareTo(o.getFile().getAbsoluteFile().getName());
	}

	public Metadata getMetadata() {
		return metadata;
	}
}
